# coding=gbk
import pywintypes,time
from excelutils import ExcelDocument

ed = ExcelDocument()
ed.open("D:\pythonwin\sample.xlsx")
try:
    for i in ed.get_sheets_names():
        print i
    sheet1 = ed.sheets[1]
    sheet1.cell(1,1).value="This is a test"
    print sheet1.nrows
    print sheet1.ncols

    sheet2 = ed.get_sheet_by_name("CPU_ALL")
    sheet2.cell(1,1).value="0:00:22"
    a=sheet2.cell(2,1).value
    print a
    c = time.strptime(a,"%H:%M:%S")
    print c
    ed.save()

except pywintypes.com_error, detail:
    print "Total info    :%s\n"    % str(detail.args)
    print "Status        :%s"    % detail.strerror
    print "Error message :%s"    % detail[1].encode("cp950")
    print "Error Code    :%s"    % detail.hresult
finally:
    ed.close()
    ed.quit()

